
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>员工管理</title>
    <#--<%@include file="/WEB-INF/views/common/link.jsp" %>-->
    <#include "../common/link.ftl">
    <script src="/js/plugins/messager/jquery.bootstrap.min.js"></script>
    <script src="js/jquery/jquery.min.js"></script>
    <script>
         $(function () {
                $('.btn_input').click(function () {
                    $("#editForm")[0].reset();

                    //有数据的话拿到数据并回显
                    var data = $(this).data('json');
                    console.log(data);
                       if(data){     //编辑操作
                           $("#editForm input[name=id]").val(data.id);
                           $("#editForm input[name=name]").val(data.name);
                           $("#editForm input[name=number]").val(data.number);
                           $("#editForm select[name='employee.id']").val(data.employeeId);


                       }
                     $("#inputModel").modal('show');
                })


             $(".btn-submit").click(function () {
                 /*使用jquery-form 表单 异步提交*/
                 $("#editForm").ajaxSubmit(handlerMessage)
             })

         })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
   <#-- <%@include file="/WEB-INF/views/common/navbar.jsp" %>-->
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
       <#--<c:set var="currentMenu" value="classinfo"/>-->
       <#assign currentMenu="classinfo">
<#--    <%@include file="/WEB-INF/views/common/menu.jsp" %>-->
       <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>班级管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 10px;">
                    <form class="form-inline" id="searchForm" action="/classinfo/list.do" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label for="keyWord">关键字:</label>
                            <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}"
                                   placeholder="请输入班级名称">
                        </div>
                        <div class="form-group">
                            <label for="dept"> 班主任:</label>
                            <select class="form-control" id="classinfo" name="employeeId">
                                <option value="-1">全部</option>
                                <#if employee??>
                                <#list employee as dept >
                                   <option value="${(dept.id)!}">${(dept.name)!}</option>
                                </#list>
                                </#if>
                              <#--  <c:forEach items="${depts}" var="d">
                                    <option value="${d.id}">${d.name}</option>
                                </c:forEach>-->
                            </select>
                            <script>
                                $("#classinfo option[value='${qo.employeeId!}']").prop("selected", true);
                            </script>
                        </div>
                        <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span>
                            查询
                        </button>
                        <a href="#" class="btn btn-success btn_redirect btn_input">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>

                    </form>
                </div>
                <table class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>班级名称</th>
                        <th>班级人数</th>
                        <th>班主任</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <#list pageResult.list as classinfo>
                   <#-- <c:forEach items="${pageResult.date}" var="classinfo" varStatus="vs">-->
                        <tr>
                            <td>${classinfo_index+1}</td>
                            <td>${classinfo.name!}</td>
                            <td>${classinfo.number!}</td>
                            <td>${(classinfo.employee.name)!}</td>
                            <td>
                                <a href="#" class="btn btn-info btn-xs btn_redirect btn_input" data-json='${(classinfo.json)!}'>
                                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                                </a>
                                <a href="#" class="btn btn-danger btn-xs btn-delete"
                                   data-xxx="${classinfo.id}"
                                >
                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                </a>

                            </td>
                        </tr>
                  </#list>
               <#--     <%--删除--%>-->
                    <script>
                        $(".btn-delete").click(function () {
                            var $xxx = $(this).data("xxx");
                            $.messager.model = {
                                ok: {text: '确认'},
                                cancel: {text: '取消'}
                            }
                            //确认框
                            $.messager.confirm('警告', '数据将被删除!', function () {
                                //点击确定后的回调函数  
                                $.get("/classinfo/delete.do", "id=" + $xxx, function (date) {
                                    if (date.success) {
                                        $.messager.popup("删除成功,两秒后自动刷新");
                                        setTimeout(function () {
                                            window.location.reload();
                                        }, 2000);
                                    } else {
                                        $.messager.popup(date.msg);
                                    }
                                })
                            });
                        });
                    </script>
                </table>
                <!--分页-->
             <#--   <%@include file="/WEB-INF/views/common/page.jsp" %>-->
                    <#include "../common/page.ftl">
               <#-- <div style="text-align: center;">
                    <ul id="pagination" class="pagination"></ul>
                    <script>
                        $("#pagination").twbsPagination({
                            totalPages: ${pageResult.totalPage},
                            startPage: ${pageResult.currentPage},
                            visiblePages: 5,
                            first: "首页",
                            prev: "上页",
                            next: "下页",
                            last: "尾页",
                            onPageClick: function (event, page) { //点击页码的时候会执行的方法
                                $("#currentPage").val(page);
                                $("#searchForm").submit();
                            }
                        });
                    </script>
                </div>-->
            </div>
        </section>
    </div>
  <#--  <%@include file="/WEB-INF/views/common/footer.jsp" %>-->
                    <#include "../common/footer.ftl">
</div>






<#--模态框-->
<div class="modal fade" id="inputModel" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">班级添加编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/classinfo/saveOrUpdate.do" method="post" id="editForm">
                    <input type="text"  name="id" hidden>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-2 control-label">名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="name" name="name"
                                   placeholder="请输入班级名称">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-2 control-label">人数：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="number" name="number"
                                   placeholder="请输入部门编码">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-2 control-label">教师：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="dept" name="employee.id">
                                     <#list employee as classinfo>
                                               <option value="${(classinfo.id)!}">${(classinfo.name)!}</option>
                                     </#list>
                            </select>
                        </div>
                    </div>

                </form>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
</html>
